--[[
读取一个二进制文件，发送tcp，读取相应（binary)
simple:
  connect to socket
  send byte
  get receive
  close

prepare:
  echo "foobar" > /tmp/foo.txt
  sudo luarocks install luasocket
  while true; do echo -e "HTTP/1.1 200 OK\r\n\r\nX\r\n" | nc -l 8888; done
--]]

-- local binFile='/home/wzq/workspace/lua_snippet/lua_socket/bin.dat'  --16 bytes
local sock = require('socket')
local host = 'localhost'
local port = 2181


local f = assert(io.open('./bin.dat','rb'))
local bytes = f:read(28)


local conn = assert(sock.connect(host, port))
conn:send(bytes)

local s, status, partial = conn:receive('*a')
print(s)

conn:close()

